package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ExpEquManager;
import com.ruoyi.system.service.IExpEquManagerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实验器材信息Controller
 * 
 * @author kk
 * @date 2023-06-20
 */
@RestController
@RequestMapping("/system/exp_equ_manager")
public class ExpEquManagerController extends BaseController
{
    @Autowired
    private IExpEquManagerService expEquManagerService;

    /**
     * 查询实验器材信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_manager:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpEquManager expEquManager)
    {
        startPage();
        List<ExpEquManager> list = expEquManagerService.selectExpEquManagerList(expEquManager);
        return getDataTable(list);
    }

    /**
     * 导出实验器材信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_manager:export')")
    @Log(title = "实验器材信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpEquManager expEquManager)
    {
        List<ExpEquManager> list = expEquManagerService.selectExpEquManagerList(expEquManager);
        ExcelUtil<ExpEquManager> util = new ExcelUtil<ExpEquManager>(ExpEquManager.class);
        util.exportExcel(response, list, "实验器材信息数据");
    }

    /**
     * 获取实验器材信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_manager:query')")
    @GetMapping(value = "/{equID}")
    public AjaxResult getInfo(@PathVariable("equID") String equID)
    {
        return success(expEquManagerService.selectExpEquManagerByEquID(equID));
    }

    /**
     * 新增实验器材信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_manager:add')")
    @Log(title = "实验器材信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpEquManager expEquManager)
    {
        return toAjax(expEquManagerService.insertExpEquManager(expEquManager));
    }

    /**
     * 修改实验器材信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_manager:edit')")
    @Log(title = "实验器材信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpEquManager expEquManager)
    {
        return toAjax(expEquManagerService.updateExpEquManager(expEquManager));
    }

    /**
     * 删除实验器材信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_manager:remove')")
    @Log(title = "实验器材信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equIDs}")
    public AjaxResult remove(@PathVariable String[] equIDs)
    {
        return toAjax(expEquManagerService.deleteExpEquManagerByEquIDs(equIDs));
    }
}
